<?
	layout("/inc/layout.html",{title:"数据加工系统-首页",htmlType:"index",pageName:"home_index"}){
?>
<div id="cl-wrapper" class="fixed-menu" style="padding-top: 0px;  ">

    <div class="container-fluid" id="pcont">
        <div class="cl-mcont" >

            <!-- row start -->
                <div class="col-lg-12" style="margin-top: 80px;">

                    <div style="float: right;">
                        <a href="/package/index.html" type="button" class="btn btn-success" onclick=""><i class="fa fa-reply"></i> 返回 </a>
                    </div>

                </div>

                <div class="col-lg-12">
                    <table class="table table-bordered" id="datatable" >
                        <thead>
                        <tr>
                            <th>序号</th>
                            <th>包名称</th>
                            <th>包路径</th>
                            <th>打包时间</th>
                            <th>包大小</th>
                            <th>可操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr>
                            <td>任务ID</td>
                            <td>任务ID</td>
                            <td>所属项目</td>
                            <td>所属资源库</td>
                            <td>数据源</td>
                            <td>可操作</td>
                        </tr>
                        </tbody>
                    </table>
                    <div id="page1" style="text-align: center; margin-top: 20px;"></div>
                </div>
            </div>
        </div>
    </div>
</div>
<?
    }
?>

<script type="text/javascript">

    var cur;
    $(function(){
        list(1);
    });

    function list(curr){
        $.ajax({
            type : "post",
            url : "/packList",
            dataType : "json",
            data:{
                "page": curr || 1
            },
            success : function(data) {
                var html = '';
                for(var i=0;i<data.listsize;i++){
                    html += '<tr>';
                    html += '<td>'+(i+1)+'</td>';
                    html += '<td>'+data.result[i].name+'</td>';
                    html += '<td>'+data.result[i].path+'</td>';
                    html += '<td>'+data.result[i].create_time+'</td>';
                    html += '<td>'+data.result[i].size+'</td>';
                    html += '<td><button type="button" class="btn btn-success" onclick="downloadfile(\''+data.result[i].name+'\')">下载</button></td>';
                    html += '</tr>';
                }

                $("#datatable tbody").html(html);

                laypage({
                    cont : document.getElementById("page1"), //容器。值支持id名、原生dom对象，jquery对象,
                    pages : data.pageSize, //总页数
                    skip : false, //是否开启跳页
                    skin : 'molv', //加载内置皮肤，也可以直接赋值16进制颜色值，如:#c00
                    curr : curr || 1,
                    last : data.pageSize,
                    groups : 6,//连续显示分页数
                    jump : function(obj, first) { //触发分页后的回调
                        if (!first) { //点击跳页触发函数自身，并传递当前页：obj.curr
                            list(obj.curr)
                            var curr = obj.curr;
                            cur = obj.curr;
                        }
                    }
                });
            },
            error: function(data) {
            }
        });
    }
    function downloadfile(name){
       window.location.href='/downloadfile?name=' + name;
    }
</script>

